home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / Pdmod / modules / libraries / mpega.m < prev    next >
Encoding:
Text File  |  2002-10-28  |  5.1 KB  |  136 lines

  1. /*------------------------------------------------------------------------------
  2.  
  3.     File    :   MPEGA.h
  4.  
  5.     Author  :   Stéphane TAVENARD
  6.  
  7.     $VER:   MPEGA.h  2.0  (21/06/1998)
  8.  
  9.     (C) Copyright 1997-1998 Stéphane TAVENARD
  10.         All Rights Reserved
  11.  
  12.     #Rev|   Date   |                      Comment
  13.     ----|----------|--------------------------------------------------------
  14.     0   |25/10/1997| Initial revision                                     ST
  15.     1   |21/06/1998| Added MPEGA_scale                                    ST
  16.  
  17.     ------------------------------------------------------------------------
  18.  
  19.     MPEGA decoder library definitions
  20.  
  21. ------------------------------------------------------------------------------*/
  22. #define MPEGA_VERSION  2        /* #1 */
  23.  
  24. MODULE  'utility/hooks'
  25.  
  26. /* Controls for decoding */
  27. /* Qualities */
  28.  
  29. #define MPEGA_QUALITY_LOW     0
  30. #define MPEGA_QUALITY_MEDIUM  1
  31. #define MPEGA_QUALITY_HIGH    2
  32.  
  33. /*
  34.    Bitstream Hook function is called like (SAS/C syntax):
  35.  
  36.  
  37.    ULONG __saveds __asm HookFunc( register __a0 struct Hook  *hook,
  38.                                   register __a2 APTR          handle,
  39.                                   register __a1 MPEGA_ACCESS *access );
  40.  
  41.    MPEGA_ACCESS struct specify bitstream access function & parameters
  42.  
  43.    access->func == MPEGA_BSFUNC_OPEN
  44.       open the bitstream
  45.       access->data.open.buffer_size is the i/o block size your read function can use
  46.       access->data.open.stream_size is the total size of the current stream
  47.                                     (in bytes, set it to 0 if unknown)
  48.       return your file handle (or NULL if failed)
  49.    access->func == MPEGA_BSFUNC_CLOSE
  50.       close the bitstream
  51.       return 0 if ok
  52.    access->func == MPEGA_BSFUNC_READ
  53.       read bytes from bitstream.
  54.       access->data.read.buffer is the destination buffer.
  55.       access->data.read.num_bytes is the number of bytes requested for read.
  56.       return # of bytes read or 0 if EOF.
  57.    access->func == MPEGA_BSFUNC_SEEK
  58.       seek into the bitstream
  59.       access->data.seek.abs_byte_seek_pos is the absolute byte position to reach.
  60.       return 0 if ok
  61. */
  62.  
  63. #define MPEGA_BSFUNC_OPEN   0
  64. #define MPEGA_BSFUNC_CLOSE  1
  65. #define MPEGA_BSFUNC_READ   2
  66. #define MPEGA_BSFUNC_SEEK   3
  67.  
  68. OBJECT MPEGA_ACCESS                                     /* Decoding output settings */
  69.         func:LONG,                                   /* MPEGA_BSFUNC_xxx */
  70.         OBJECT data
  71.                 OBJECT open
  72.                         stream_name:PTR TO UBYTE,    /* in */
  73.                         buffer_size:LONG,            /* in */
  74.                         stream_size:LONG             /* out */
  75.                 ENDOBJECT,
  76.                 OBJECT read
  77.                         buffer:VOID,    /* in/out */
  78.                         num_bytes:LONG         /* in */
  79.                 ENDOBJECT,
  80.                 OBJECT seek
  81.                         byte_seek_pos:LONG     /* out */
  82.                 ENDOBJECT
  83.         ENDOBJECT
  84.  
  85. OBJECT MPEGA_OUTPUT          /* Decoding layer settings */
  86.         freq_div:WORD,    /* 1, 2 or 4 */
  87.         quality:WORD,     /* 0 (low) .. 2 (high) */
  88.         freq_max:LONG     /* for automatic freq_div (if mono_freq_div == 0) */
  89.  
  90. OBJECT MPEGA_LAYER                /* Full control structure of MPEG Audio decoding */
  91.         force_mono:WORD,        /* 1 to decode stereo stream in mono, 0 otherwise */
  92.         mono:MPEGA_OUTPUT,      /* mono settings */
  93.         stereo:MPEGA_OUTPUT     /* stereo settings */
  94.  
  95. OBJECT MPEGA_CTRL                    /* MPEG Audio modes */
  96.         bs_access:PTR TO Hook,      /* NULL for default access (file I/O) or give your own bitstream access */
  97.         layer_1_2:MPEGA_LAYER,      /* Layer I & II settings */
  98.         layer_3:MPEGA_LAYER,        /* Layer III settings */
  99.         check_mpeg:WORD,            /* 1 to check for mpeg audio validity at start of stream, 0 otherwise */
  100.         stream_buffer_size:LONG     /* size of bitstream buffer in bytes (0 -> default size) */
  101.  
  102. #define MPEGA_MODE_STEREO    0
  103. #define MPEGA_MODE_J_STEREO  1
  104. #define MPEGA_MODE_DUAL      2
  105. #define MPEGA_MODE_MONO      3
  106.  
  107. OBJECT MPEGA_STREAM
  108.         norm:WORD,             /* 1 or 2 */
  109.         layer:WORD,            /* 1..3 */
  110.         mode:WORD,             /* 0..3  (MPEGA_MODE_xxx) */
  111.         bitrate:WORD,          /* in kbps */
  112.         frequency:LONG,        /* in Hz */
  113.         channels:WORD,         /* 1 or 2 */
  114.         ms_duration:ULONG,     /* stream duration in ms */
  115.         private_bit:WORD,      /* 0 or 1 */
  116.         copyright:WORD,        /* 0 or 1 */
  117.         original:WORD,         /* 0 or 1 */
  118.         dec_channels:WORD,     /* decoded channels 1 or 2 */
  119.         dec_quality:WORD,      /* decoding quality 0..2 */
  120.         dec_frequency:LONG,    /* decoding frequency in Hz */
  121.         handle:VOID
  122.  
  123. #define MPEGA_MAX_CHANNELS  2           // Max channels
  124. #define MPEGA_PCM_SIZE      1152        // Max samples per frame
  125.  
  126. /* Error codes */
  127.  
  128. #define MPEGA_ERR_NONE      0
  129. #define MPEGA_ERR_BASE      0
  130. #define MPEGA_ERR_EOF       (MPEGA_ERR_BASE-1)
  131. #define MPEGA_ERR_BADFRAME  (MPEGA_ERR_BASE-2)
  132. #define MPEGA_ERR_MEM       (MPEGA_ERR_BASE-3)
  133. #define MPEGA_ERR_NO_SYNC   (MPEGA_ERR_BASE-4)
  134. #define MPEGA_ERR_BADVALUE  (MPEGA_ERR_BASE-5)  /* #1 */
  135.  
  136.